home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMIBEST4.ADF
/
AmigaBasicStuff
/
YoYo
< prev
next >
Wrap
Text File
|
1987-07-22
|
3KB
|
71 lines
'Path: uwvax!seismo!lll-crg!ucdavis!ucbvax!vax135!cjp
'From: uwvax!vax135!cjp (Charles Poirier)
'Newsgroups: net.micro.amiga
'Subject: Yo-Yo source (Basic), possible Collisions BUG
'Date: 27 Jan 8604:51:31 GMT
'Organization: AT&T Bell Labs, Holmdel, NJ
'I just got my Amiga (sans Development kit so far), running V1.1 of
'kickstart AND of AmigaBasic. my first AmigaBasic program *almost*
'works, but there is something funny going ON with the detection of
'Collisions of a BOB (blitter object) with the WINDOW edge. In the
'following program, the BOB bounces OFF edges normally, *except* when it
'hits the *same edge* twice In a row. the second AND ALL subsequent
'times the BOB touches the same edge, no COLLISION is detected. Having
'the BOB bounce OFF a different edge re-enables bounces ON the first
'edge but disables them ON the most recent edge. Other anomalous
'behavior: when the BOB passes through a WINDOW edge due TO missing a
'COLLISION, it sometimes "bounces" OFF of the OFF-SCREEN continuation of
'a perpendicular "edge" (this I infer From where the BOB re-enters the
'SCREEN)0! but sometimes it *doesn't* bounce, but passes through this
'second edge AS well. this seems TO depend ON which edge is missing
'Collisions, *AND* ON which perpendicular edge. I tried adding a
'"collision on" In subr "bouncy", but it had no effect AT ALL (AS indeed
'is implied In the COLLISION documentation) so I removed it.
'Please helpPRINT is this a BUG In my program, In AmigaBasic, In the Amiga
'kernel, OR In the COLLISION detection hardwarePRINT I hope it's just
'something I am neglecting TO RESET, but I can't figure out what from
'the AmigaBasic manual. Note, the example program under OBJECT.SHAPE
'In the AmigaBasic manual doesn't use acceleration, so it would never
'find any BUG dealing with hitting the same side twice In a row.
entrypoint:
'yoyo: program to have an object yo-yo around the mouse pointer.
ON COLLISION GOSUB bouncy
COLLISION ON
OPEN "i", #1, "Ball" 'output of my objedit run
OBJECT.SHAPE 1, INPUT$(LOF(1),1) 'defines the object
CLOSE 1
foo% = MOUSE(0) 'sample the mouse position, then give it to object 1
OBJECT.X 1, MOUSE(1): OBJECT.Y 1, MOUSE(2)
OBJECT.VX 1, 40
ax.kludge! = .033: ay.kludge! = .05
OBJECT.ON
OBJECT.START
WHILE (MOUSE(0) <> 1) 'sample mouse position, exit on click left
xdiff& = MOUSE(1) - OBJECT.X(1): ydiff& = MOUSE(2) - OBJECT.Y(1)
xsgn% = SGN(xdiff&): ysgn% = SGN(ydiff&)
xreal! = CSNG(xdiff&): yreal! = CSNG(ydiff&)
xreal! = ABS(xreal! * xreal! * xreal!)
yreal! = ABS(yreal! * yreal! * yreal!)
'adjust acceleration towards current mouse position as 3/2 power of dist
OBJECT.AX 1, (ax.kludge! * SQR(xreal!) * xsgn%)
OBJECT.AY 1, (ay.kludge! * SQR(yreal!) * ysgn%)
WEND
OBJECT.CLOSE
END
bouncy: 'collision interrupt subroutine
wall% = COLLISION(1)
IF (wall% = -1) OR (wall% = -3) THEN
OBJECT.VY 1, (-OBJECT.VY(1) * .5) 'bounce; reverse and halve y-component
ELSEIF (wall% = -2) OR (wall% = -4) THEN
OBJECT.VX 1, (-OBJECT.VX(1) * .5)
END IF
OBJECT.START
RETURN